package com.dxt.springmvcdemo.validators;

import com.dxt.springmvcdemo.annotation.Salary;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

import java.math.BigDecimal;

/**
 * BelongProject: springMVC
 * BelongPackage: com.dxt.springmvcdemo.validators
 * Description:
 *
 * @Author 段鑫涛
 * @Create 2025/4/14 21:36
 * @Version 1.0
 */
public class MySalaryValidator implements ConstraintValidator<Salary, BigDecimal> {
    @Override
    public boolean isValid(BigDecimal bigDecimal, ConstraintValidatorContext constraintValidatorContext) {
        return bigDecimal != null && bigDecimal.compareTo(new BigDecimal(0)) > 0 ? true : false;
    }
}
